{include file="head" title="内容修改" /}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">内容修改</div>
        <div class="layui-card-body" style="padding: 15px;">
            <form id="form" class="layui-form" action="" style="width:80%;">
                <input type="hidden" name="id" value="{$s->id}">
                <div class="layui-form-item">
                    <label class="layui-form-label">设备编号<span class="form_require">*</span></label>
                    <div class="layui-input-block w50">
                        <input disabled type="text" name="name" value="{$s->machineid|default=''}" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">机械类型<span class="form_require">*</span></label>
                    <div class="layui-input-block w50">
                        <select disabled name="type" lay-filter="type" lay-verify="required">
                            <option value=""></option>
                            {:get_options((Array)$types,'id',$s->type,'name')}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">设备系统<span class="form_require">*</span></label>
                    <div class="layui-input-block w50">
                        <select disabled name="system_id" lay-filter="system_id" lay-verify="required">
                            <option value=""></option>
                            {:get_options((Array)$systems,'id',$s->system_id,'name')}
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block w50">
                        <input name="create_at" type="text" disabled id="create_at" value="{$s->create_at|default=''}"  autocomplete="off" lay-verify="required" class="layui-input"/>
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">所属公司</label>
                    <div class="layui-input-block w50">
                        <select name="company_id" lay-filter="company_id" lay-verify="required">
                            <option value=""></option>
                            {:get_option($s->company_id,$companys)}
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">使用时间</label>
                    <div class="layui-input-block w50">
                        <input name="service_at" type="text" id="service_at" value="{$s->service_at|default=''}"  autocomplete="off" lay-verify="required" class="layui-input"/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        {:get_radio($s->status,\\app\\common\\model\\Machines::machineStatus(),'status')}
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
                        <button type="button" class="layui-btn layui-btn-primary" onclick="javascript:history.back(-1)">返回</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
    layui.config({
        base: '{$Think.const.admin_tpl}/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'upload', 'laydate'], function () {
        var $ = layui.$
            , layer = layui.layer
            , laydate = layui.laydate
            , upload = layui.upload
            , form = layui.form;

        laydate.render({
            elem: '#create_at'
            , type: 'datetime'
            , format: 'yyyy-M-d H:m:s'
        });

        laydate.render({
            elem: '#service_at'
            , type: 'datetime'
            , format: 'yyyy-M-d H:m:s'
        });

        /* 监听提交 */

        form.on('submit(sub)', function (data) {
            console.log($("#form").serialize());
            $.ajax({
                url: "/admin/machines/contents_submit/",
                type: 'post',
                data: $("#form").serialize(),
                dataType: 'json',
                success: function (data) {
                    if (data.status == 1)
                    {
                        layer.confirm(data.msg + '请选择？', {
                            btn: ['继续添加', '返回列表'] //按钮
                        }, function () {
                            location.href = '/admin/machines/add.html';
                        }, function () {
                            location.href = '/admin/machines/index.html';
                        });
                    }
                    else
                    {
                        layer.msg(data.msg);
                    }
                },
                error: function (msg) {
                    alert(" 数据保存失败！" + msg);
                }
            });

            return false;
        });
    });
</script>
{include file="foot" /}
